//
//  LYBaseTableViewController.swift
//  微博
//
//  Created by liuerying on 16/5/21.
//  Copyright © 2016年 liuerying. All rights reserved.
//

import UIKit
//遵守代理协议
class LYBaseTableViewController: UITableViewController ,LYVisitorViewDelgate{

    //根据用户时候登录,判断是访客视图还是登录页面
    var userLogin = LYUserAccountModel.sharedAccountViewModel.userLogin
    
    lazy var visitorLoginView: LYVisitorView = LYVisitorView()
    
    override func loadView() {
        
        //如果客户登录
        if userLogin{
            //显示tableView
            super.loadView()
            
            //如果没有登录
        }else{
            //显示访客视图
            self.loadVisitorView()
        }
    }
    
    
    func loadVisitorView(){
        
        view = visitorLoginView
        //设置代理
        visitorLoginView.vistorDelgate = self
        
    }
    

    //MARK:用户
    func userWillLogin() {
       
        let VC = LYOAuthViewController()
//        let VC = LYWelcomeController()
        let nav = UINavigationController(rootViewController: VC)
    
        
        presentViewController(nav, animated: true, completion: nil)
        
    }
    
    
    func userWillRegister() {
        print("注册")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Uncomment the following line to preserve selection between presentations
        // self.clearsSelectionOnViewWillAppear = false

        // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
        // self.navigationItem.rightBarButtonItem = self.editButtonItem()
    }



    /*
    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCellWithIdentifier("reuseIdentifier", forIndexPath: indexPath)

        // Configure the cell...

        return cell
    }
    */

    /*
    // Override to support conditional editing of the table view.
    override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
        // Return false if you do not want the specified item to be editable.
        return true
    }
    */

    /*
    // Override to support editing the table view.
    override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
        if editingStyle == .Delete {
            // Delete the row from the data source
            tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
        } else if editingStyle == .Insert {
            // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
        }    
    }
    */

    /*
    // Override to support rearranging the table view.
    override func tableView(tableView: UITableView, moveRowAtIndexPath fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath) {

    }
    */

    /*
    // Override to support conditional rearranging of the table view.
    override func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool {
        // Return false if you do not want the item to be re-orderable.
        return true
    }
    */

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
